package com.ophiux.FeverManagement.infratructure.repository;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.ophiux.FeverManagement.domain.entity.RbPatientTreatmentCurrent;
import com.ophiux.FeverManagement.domain.repository.IPatientTreatmentCurrentRepository;
import com.ophiux.FeverManagement.infratructure.TableEnum;
import com.ophiux.FeverManagement.infratructure.mapper.RbPatientTreatmentCurrentMapper;
import com.ophiux.micro.core.infrastructure.TbableUniqueIDFactory;
import com.ophiux.utils.common.StringUtil;
import com.ophiux.utils.exception.OphiuxRepositoryException;

import lombok.extern.slf4j.Slf4j;

@Repository
@Slf4j
public class PatientTreatmentCurrentRepository implements IPatientTreatmentCurrentRepository {

	@Autowired
	RbPatientTreatmentCurrentMapper patientTreatmentCurrentMapper;
	
	@Override
	public String save(RbPatientTreatmentCurrent model) throws OphiuxRepositoryException {
		String ID = model.getID();
		try {
			if (StringUtil.isEmpty(ID)) {
				ID = TbableUniqueIDFactory.instance().createUniqueID(TableEnum.TABLE_SQE_RB_PATIENT_TREATMENT_CURRENT.toString());
				model.setID(ID);
				patientTreatmentCurrentMapper.insert(model);
			} else {
				patientTreatmentCurrentMapper.update(model);
			}
		} catch (Exception e) {
			e.printStackTrace();
			log.info("数据库执行异常,异常信息", e);
			throw new OphiuxRepositoryException(e);
		}
		return ID;
	}

	@Override
	public void delete(Object uniqueId) throws OphiuxRepositoryException {
		
		
	}

	@Override
	public RbPatientTreatmentCurrent selectOneByKey(Object uniqueId) throws OphiuxRepositoryException {
		
		return null;
	}

	@Override
	public RbPatientTreatmentCurrent selectOne(Map map) throws OphiuxRepositoryException {
		
		return null;
	}

	@Override
	public List<RbPatientTreatmentCurrent> selectAll(Map map) throws OphiuxRepositoryException {
		
		return null;
	}

}
